import axios from './axios';

//搜索文章
export const searchArticles = async (query) => {
    try {
      const response = await axios.request({
        method: 'get',
        url: `/api/articles/search`,
        params: { query }
      });
      return response.data;
    } catch (error) {
      console.error('Error searching articles:', error);
      throw error;
    }
  };

  // 搜索心理测评试题
export const searchTests = async (query) => {
    try {
      const response = await axios.request({
        method: 'get',
        url: `/api/tests/global-search`,
        params: { query }
      });
      return response.data;
    } catch (error) {
      console.error('Error searching tests:', error);
      throw error;
    }
  };